public class Solution {

    public static void main(String[] args) {
        int[] nums = new int[]{2,3,5,7,65,43,356,76,54323,45};
        quickSort(nums,0,nums.length-1);
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+" ");
        }
    }
    public static void quickSort(int[] nums,int start, int end) {
        if(start >= end) {
            return;
        }
        int left = start;
        int right = end;
        int tmp = nums[left];
        while(left < right) {
            //右边走到比tmp小的位置
            while(nums[right] >= tmp &&  left < right) {
                right--;
            }
            //right位置小于left位置
            nums[left] = nums[right];
            //左边走到比tmp大的位置
            while(nums[left] <= tmp && left < right) {
                left++;
            }
            //left位置大于right位置
            nums[right] = nums[left];
        }
        nums[left] = tmp;
        //排序左边
        quickSort(nums,start,left -1);
        //排序右边
        quickSort(nums,right + 1,end);
    }
}
